package cn.iocoder.yudao.module.nmkj.controller.app.tagarticle;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.nmkj.controller.admin.tagarticle.vo.TagArticleRespVO;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.tagarticle.TagArticleDO;
import cn.iocoder.yudao.module.nmkj.service.tagarticle.TagArticleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 标签文章")
@RestController
@RequestMapping("/nmkj/tag-article")
@Validated
public class AppTagArticleController {

    @Resource
    private TagArticleService tagArticleService;

    @GetMapping("/get")
    @Operation(summary = "获得标签文章")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<TagArticleRespVO> getTagArticle(@RequestParam("id") Long id) {
        TagArticleDO tagArticle = tagArticleService.getTagArticleApp(id);
        return success(BeanUtils.toBean(tagArticle, TagArticleRespVO.class));
    }

}
